# -*- coding: utf-8 -*-

"""
@author: yangshuang
@software: PyCharm
@Project -> File：studyFastapi -> 3
@Date: 2021/11/18 17:49
"""
import uvicorn
from fastapi import FastAPI, Query

app = FastAPI()

'''查询参数Query参数的其他校验'''

@app.get("/items/")
async def read_items(q: str = Query(None, min_length=3, max_length=50), regex="^fixedquery$"):
    results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
    if q:
        results.update({"q": q})
    return results


if __name__ == '__main__':
    uvicorn.run(app='2:app', host="127.0.0.1", port=8000, reload=True, debug=True)
